package operation;

import book.Book;
import book.BookList;
import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.util.Scanner;

public class ReturnOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("归还图书");
        Scanner scan=new Scanner(System.in);
        System.out.println("请输入书名");
        String name=scan.nextLine();
        int size=bookList.getSize();
        for(int i=0;i<size;i++){
            Book book=bookList.getBooks(i);
            if(book.getName().equals(name)){
                if(book.getState()) {
                    book.setState(false);
                    System.out.println("归还成功");
                }else{
                    System.out.println("归还失败");
                }
                return;
            }
        }
        System.out.println("没有此书");
    }
}
